home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
DISEEK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-09-20
|
3KB
|
89 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: diseek.c
// Title: Data File I/O Library
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains code to position the file pointer in a virtual file.
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <di.h>
//----------------------------------------------------------------------------
// Description: Position file pointer in a random access file.
// Parameters: hlf Logical file handle
// fpos File position to seek to.
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_E DioSeek(HLF hlf, FPOS fpos)
{
Assert(hlf >= 0 && hlf < MAX_LOGICAL_FILES);
Assert(di.logical[hlf].fUsed);
if (fpos < 0)
fpos = 0;
di.logical[hlf].fl &= ~LF_EOF;
if ((unsigned)fpos >= di.logical[hlf].flen)
{
fpos = di.logical[hlf].flen;
di.logical[hlf].fl |= LF_EOF;
}
di.logical[hlf].fpos = fpos;
return TRUE;
}
//----------------------------------------------------------------------------
// Description: Position file pointer in a block file.
// Parameters: hlf Logical file handle
// usBlock Block to seek to
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_E DioSeekBlock(HLF hlf, LONG lBlock)
{
FPOS fpos;
Assert(hlf >= 0 && hlf < MAX_LOGICAL_FILES);
Assert(di.logical[hlf].fUsed);
fpos = (FPOS)lBlock * (FPOS)di.logical[hlf].usBlockSize;
return DioSeek(hlf, fpos);
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------